package com.yunxi.service.localService.vehicle.impl;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.dao.vehicle.VehicleCertMapper;
import com.yunxi.model.vehicle.VehicleCert;
import com.yunxi.service.localService.vehicle.VehicleCertService;
import com.yunxi.vehicle.pojo.VehicleCertVO;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * <p>
 * 合格证信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-22
 */
@Service
public class VehicleCertServiceImpl extends ServiceImplPlus<VehicleCertMapper, VehicleCert> implements VehicleCertService {

    @Override
    public VehicleCertVO getByVin(String vin) {
        return baseMapper.getByVin(vin);
    }

    @Override
    public void saveOrUpdateByVin(VehicleCert vc) {
        VehicleCertVO v = getByVin(vc.getVin());
        if(v==null){
            baseMapper.insert(vc);
        }else{
            vc.setVehicleCertId(v.getVehicleCertId());
            baseMapper.updateById(vc);
        }
    }

    /**
     * 通过VIN查询批售单付款方式,找到渠道付款融资机构关系主键
     * @param vin
     * @return
     */
    @Override
    public String getPatWayByVin(String vin) {
        return baseMapper.getPayWayByVin(vin);
    }

    /**
     * 通过VIN查询批售单付款方式
     * @param vin
     * @return
     */
    @Override
    public String getPatWay(String vin) {
        return baseMapper.getPayWay(vin);
    }

    /**
     * 合格证管理查询分页
     * @param vehicleCertVO
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo managePage(VehicleCertVO vehicleCertVO, Integer pageNum, Integer pageSize) {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<VehicleCertVO> list = baseMapper.managePage(vehicleCertVO);
        PageInfo<VehicleCertVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
